<template>
	<view class="content">
		<uni-easyinput 
			v-model="NeteaseCloudMusicApi" 
			placeholder="NeteaseCloudMusicApi" 
			@blur="NeteaseCloudMusicApiset()"
		></uni-easyinput>
		<button @click="findCloudMusic()">NeteaseCloudMusic单曲导入</button>
		<button @click="musicListInput()">NeteaseCloudMusic歌单导入</button>
		<uni-easyinput
			v-model="serverurl" 
			placeholder="服务器URL" 
			@blur="serverurlset()"
		></uni-easyinput>
		<button @click="musicGroupSet()">歌单管理</button>
		<button @click="upmusiclo()">本地歌曲上传</button>
		<button @click="upmusicloal()">本地专辑上传</button>
		<button @click="userset()">个人设置</button>
		<uni-link href="https://www.ssdcc.cn/" text="https://www.ssdcc.cn/"><button>客户端以及后台服务包下载</button></uni-link>
		<!-- <button>个人信息设置</button>
		<button>关于本应用</button> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'about',
				NeteaseCloudMusicApi:'',
				serverurl:''
			}
		},
		onLoad() {
			try {
				const value = uni.getStorageSync('NeteaseCloudMusicApi')
				if (value) {
					this.NeteaseCloudMusicApi = value
				}
			} catch (e) {
				uni.showToast({
					title: e.message,
					duration: 2000,
					icon:"error"
				})
			}
			try {
				const value = uni.getStorageSync('serverurl')
				if (value) {
					this.serverurl = value
				}
			} catch (e) {
				uni.showToast({
					title: e.message,
					duration: 2000,
					icon:"error"
				})
			}
		},
		methods: {
			musicGroupSet(){
				uni.navigateTo({url: 'music/servermusicgroup'})
			},
			upmusicloal(){
				uni.navigateTo({url: 'music/upalname'})
			},
			userset(){
				uni.navigateTo({url: 'user'})
			},
			serverurlset(){
				try {
					uni.setStorageSync('serverurl', this.serverurl)
					uni.showToast({
						title: '设置成功',
						duration: 2000,
					});
				} catch (e) {
					uni.showToast({
						title: e.message,
						duration: 2000,
						icon:"error"
					});
				}
			},
			musicListInput(){
				uni.navigateTo({url: 'music/findcloudmusiclist'})
			},
			upmusiclo(){
				uni.navigateTo({url: 'music/upmusic'})
			},
			NeteaseCloudMusicApiset(){
				try {
					uni.setStorageSync('NeteaseCloudMusicApi', this.NeteaseCloudMusicApi)
					uni.showToast({
						title: '设置成功',
						duration: 2000,
					});
				} catch (e) {
					uni.showToast({
						title: e.message,
						duration: 2000,
						icon:"error"
					});
				}
			},
			findCloudMusic(){
				uni.navigateTo({url: 'music/findcloudmusic'})
			}
		}
	}
</script>

<style>
	.content {
	}
</style>
